﻿using System;
using ASPNETVN.PORTAL.Components.UI;
using ASPNETVN.PORTAL.Components.Helpers;

namespace QLC.Modules.SCHEDULE
{

    public enum ModulePages
    {
        ItemList,
        ItemDetail
    }

    public partial class Main : PortalModuleControl
    {
        private void LoadChildControl()
        {
            const string basePath = "~/Modules/QLC.Modules.SCHEDULE/";
            const string pageQuery = "page";
            string pageName = Request.QueryString[pageQuery];

            ModulePages page = ModulePages.ItemList;
            if (string.IsNullOrEmpty(pageName) == false)
            {
                page = (ModulePages)Enum.Parse(typeof(ModulePages), Request.QueryString[pageQuery], true);
            }

            string src = string.Format("{0}Controls/{1}.ascx", basePath, page);
            ModulePage ctl = (ModulePage)this.LoadControl(src);
            ctl.ParentControl = this;
            ContentPane.Controls.Add(ctl);
        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            this.ModuleTitle.AddUrl = HttpUrlBuilder.BuildAddEditUrl(this.ModuleID, 0, "AddEditItem");
        }

        protected void Page_Load(object sender, EventArgs e)
        {
           
            this.LoadChildControl();
        }
    }
}